package com.hogae.capital.service.impl;

import java.util.List;

import com.hogae.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hogae.capital.mapper.CapPoolAccountRecordMapper;
import com.hogae.capital.domain.CapPoolAccountRecord;
import com.hogae.capital.service.ICapPoolAccountRecordService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 资金池记录Service业务层处理
 *
 * @author hogae
 * @date 2021-02-26
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class CapPoolAccountRecordServiceImpl implements ICapPoolAccountRecordService {
    @Autowired
    private CapPoolAccountRecordMapper capPoolAccountRecordMapper;

    /**
     * 查询资金池记录
     *
     * @param id 资金池记录ID
     * @return 资金池记录
     */
    @Override
    public CapPoolAccountRecord selectCapPoolAccountRecordById(Long id) {
        return capPoolAccountRecordMapper.selectCapPoolAccountRecordById(id);
    }

    /**
     * 查询资金池记录列表
     *
     * @param capPoolAccountRecord 资金池记录
     * @return 资金池记录
     */
    @Override
    public List<CapPoolAccountRecord> selectCapPoolAccountRecordList(CapPoolAccountRecord capPoolAccountRecord) {
        return capPoolAccountRecordMapper.selectCapPoolAccountRecordList(capPoolAccountRecord);
    }

    /**
     * 新增资金池记录
     *
     * @param capPoolAccountRecord 资金池记录
     * @return 结果
     */
    @Override
    public int insertCapPoolAccountRecord(CapPoolAccountRecord capPoolAccountRecord) {
        capPoolAccountRecord.setCreateTime(DateUtils.getNowDate());
        return capPoolAccountRecordMapper.insertCapPoolAccountRecord(capPoolAccountRecord);
    }

    /**
     * 修改资金池记录
     *
     * @param capPoolAccountRecord 资金池记录
     * @return 结果
     */
    @Override
    public int updateCapPoolAccountRecord(CapPoolAccountRecord capPoolAccountRecord) {
        capPoolAccountRecord.setUpdateTime(DateUtils.getNowDate());
        return capPoolAccountRecordMapper.updateCapPoolAccountRecord(capPoolAccountRecord);
    }

    /**
     * 批量删除资金池记录
     *
     * @param ids 需要删除的资金池记录ID
     * @return 结果
     */
    @Override
    public int deleteCapPoolAccountRecordByIds(Long[] ids) {
        return capPoolAccountRecordMapper.deleteCapPoolAccountRecordByIds(ids);
    }

    /**
     * 删除资金池记录信息
     *
     * @param id 资金池记录ID
     * @return 结果
     */
    @Override
    public int deleteCapPoolAccountRecordById(Long id) {
        return capPoolAccountRecordMapper.deleteCapPoolAccountRecordById(id);
    }


    @Override
    public List<CapPoolAccountRecord> selectByFromUserIdAndAmountType(CapPoolAccountRecord capPoolAccountRecord) {
        return capPoolAccountRecordMapper.selectByFromUserIdAndAmountType(capPoolAccountRecord);
    }
}
